﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Security.Cryptography;
using System.Text;

namespace TinyPMS_Jerusalem.Models
{
    public class CommonCode
    {
        public static string SHA1Encrypt(string stringToEncrypt)
        {
            SHA1 shaCreator = SHA1.Create();
            byte[] buffer = Encoding.Default.GetBytes(stringToEncrypt);   //获得需要计算的byte数组
            byte[] result = shaCreator.ComputeHash(buffer);   //计算Hash值
            StringBuilder EnText = new StringBuilder();  //将byte数组转换为string
            foreach (byte iByte in result)
            {
                EnText.AppendFormat("{0:x2}", iByte);
            }
            return EnText.ToString();
        }
    }
}